
setClass("BStickDimChooser",contains="PCADimChooser",
		prototype=prototype(
				.description="Broken Stick DimChooser"
		)
)
#general functions
Bstick <- function(.Object,reducer,...) {
	eigvLength <-length(reducer@.eigenValues)
	bstickDist <- brokenStick(eigvLength)
	
	colNumber <- 0
	eigSum <- sum(reducer@.eigenValues)
	for(i in (1:eigvLength)){
		if((bstickDist[i]) < reducer@.eigenValues[i]/eigSum){
			colNumber <-i
		}
		else{
			break;
		}
	}
	if(colNumber==0){
		warning("None of eigenvalues seem to be significant ",.Object@.description," ",reducer@.description)
		colNumber <- 1
	}
	
	return(as.integer(colNumber))
	
}
#methods
setMethod("chooseBest",
		signature=c("BStickDimChooser","PCAReducer"),
		definition= Bstick
)


setMethod("chooseBest",
		signature=c("BStickDimChooser","kPCAReducer"),
		definition= Bstick
) 
